(function () {
    myAlerts = {
        initDocumentAlerts: function () {
            var alerts = [{
                content: "发送应收账款准入（手工）申请,请审批",
                title: '预警模块',
                level:'text-danger',
                icon: 'bell',
                time: "2小时前"

            }, {
                content: "发送应收账款准入（手工）申请,请审批",
                title: '预警模块',
                level:'text-warning',
                icon: 'home',
                time: "2小时前"

            }];
            var li = document.createElement("li");
            li.className = 'nav-item dropdown'

            var li_a = document.createElement('a')
            li_a.className = 'nav-icon dropdown-toggle'
            li_a.href = "#"
            li_a.setAttribute("id", 'messagesDropdown')
            li_a.setAttribute("data-toggle", 'dropdown')
            li.appendChild(li_a)

            var li_a_div = document.createElement('div')
            li_a_div.className = "position-relative"
            li_a.appendChild(li_a_div)

            var li_a_div_i = document.createElement("i");
            li_a_div_i.className = 'align-middle';
            li_a_div_i.setAttribute("data-feather", 'bell-off')
            li_a_div.appendChild(li_a_div_i)

            // var li_a_div_span = document.createElement("span");
            // li_a_div_span.className = 'indicator'
            // li_a_div_span.innerHTML = messages.length
            // li_a_div.appendChild(li_a_div_span)

            var li_div = document.createElement('div')
            li_div.className = 'dropdown-menu dropdown-menu-lg dropdown-menu-right py-0'
            li_div.setAttribute("aria-labelledby", 'messagesDropdown')
            li_a_div.appendChild(li_div)

            var li_div_div = document.createElement('div')
            li_div_div.className = 'dropdown-menu-header'
            li_div.appendChild(li_div_div)

            var li_div_div_divpos = document.createElement('div')
            li_div_div_divpos.className = 'position-relative'
            li_div_div_divpos.innerHTML = alerts.length + '条警告'
            li_div_div.appendChild(li_div_div_divpos)

            var li_div_div_divlistgroup = document.createElement('div')
            li_div_div_divlistgroup.className = 'list-group'
            li_div.appendChild(li_div_div_divlistgroup)


            for (var index in alerts) { //遍历json数组时，这么写p为索引，0,1

                var a = document.createElement("a");
                a.className = "list-group-item"
                a.href = '#';
                li_div_div_divlistgroup.appendChild(a)

                var a_div = document.createElement('div')
                a_div.className = 'row no-gutters align-items-center'
                a.appendChild(a_div)

                var a_div_col2 = document.createElement('div')
                a_div_col2.className = 'col-2'
                a_div.appendChild(a_div_col2)

                var a_div_col2_i = document.createElement('i')
                a_div_col2_i.className =alerts[index].level
                a_div_col2_i.setAttribute("data-feather", alerts[index].icon)
                a_div_col2.appendChild(a_div_col2_i)

                var a_div_col10 = document.createElement('div')
                a_div_col10.className = 'col-10 pl-2'
                a_div.appendChild(a_div_col10)


                var a_div_col10_who = document.createElement('div')
                a_div_col10_who.className ='text-dark'
                a_div_col10_who.innerHTML = alerts[index].title
                a_div_col10.appendChild(a_div_col10_who)

                var a_div_col10_message = document.createElement('div')
                a_div_col10_message.className = 'text-muted small mt-1'
                a_div_col10_message.innerHTML = alerts[index].content
                a_div_col10.appendChild(a_div_col10_message)

                var a_div_col10_time = document.createElement('div')
                a_div_col10_time.className = 'text-muted small mt-1'
                a_div_col10_time.innerHTML = alerts[index].time
                a_div_col10.appendChild(a_div_col10_time)



            }
            return li;
        }
    };
    myMessages = {
        initDocumentMessages: function () {

            var messages = [{
                content: "发送应收账款准入（手工）申请,请审批",
                who: '朱晓磊',
                avatar: 'img/avatar/zhuxiaolei.jpg',
                time: "2小时前"

            }, {
                content: "发送天士力项目买方准入（手工）申请,请审批",
                who: '艾睿',
                avatar: 'img/avatar/airui.jpg',
                time: "2小时前",
                icon: "home"

            }];
            var li = document.createElement("li");
            li.className = 'nav-item dropdown'

            var li_a = document.createElement('a')
            li_a.className = 'nav-icon dropdown-toggle'
            li_a.href = "#"
            li_a.setAttribute("id", 'messagesDropdown')
            li_a.setAttribute("data-toggle", 'dropdown')
            li.appendChild(li_a)

            var li_a_div = document.createElement('div')
            li_a_div.className = "position-relative"
            li_a.appendChild(li_a_div)

            var li_a_div_i = document.createElement("i");
            li_a_div_i.className = 'align-middle';
            li_a_div_i.setAttribute("data-feather", 'message-circle')
            li_a_div.appendChild(li_a_div_i)

            var li_a_div_span = document.createElement("span");
            li_a_div_span.className = 'indicator'
            li_a_div_span.innerHTML = messages.length
            li_a_div.appendChild(li_a_div_span)

            var li_div = document.createElement('div')
            li_div.className = 'dropdown-menu dropdown-menu-lg dropdown-menu-right py-0'
            li_div.setAttribute("aria-labelledby", 'messagesDropdown')
            li_a_div.appendChild(li_div)

            var li_div_div = document.createElement('div')
            li_div_div.className = 'dropdown-menu-header'
            li_div.appendChild(li_div_div)

            var li_div_div_divpos = document.createElement('div')
            li_div_div_divpos.className = 'position-relative'
            li_div_div_divpos.innerHTML = messages.length + '条消息'
            li_div_div.appendChild(li_div_div_divpos)

            var li_div_div_divlistgroup = document.createElement('div')
            li_div_div_divlistgroup.className = 'list-group'
            li_div.appendChild(li_div_div_divlistgroup)


            for (var index in messages) { //遍历json数组时，这么写p为索引，0,1

                var a = document.createElement("a");
                a.className = "list-group-item"
                a.href = '#';
                li_div_div_divlistgroup.appendChild(a)

                var a_div = document.createElement('div')
                a_div.className = 'row no-gutters align-items-center'
                a.appendChild(a_div)

                var a_div_col2 = document.createElement('div')
                a_div_col2.className = 'col-2'
                a_div.appendChild(a_div_col2)

                var a_div_col2_img = document.createElement('img')
                a_div_col2_img.className = "avatar img-fluid rounded-circle"
                a_div_col2_img.src = messages[index].avatar
                a_div_col2.appendChild(a_div_col2_img)

                var a_div_col10 = document.createElement('div')
                a_div_col10.className = 'col-10 pl-2'
                a_div.appendChild(a_div_col10)


                var a_div_col10_who = document.createElement('div')
                a_div_col10_who.className = 'text-dark'
                a_div_col10_who.innerHTML = messages[index].who
                a_div_col10.appendChild(a_div_col10_who)

                var a_div_col10_message = document.createElement('div')
                a_div_col10_message.className = 'text-muted small mt-1'
                a_div_col10_message.innerHTML = messages[index].content
                a_div_col10.appendChild(a_div_col10_message)

                var a_div_col10_time = document.createElement('div')
                a_div_col10_time.className = 'text-muted small mt-1'
                a_div_col10_time.innerHTML = messages[index].time
                a_div_col10.appendChild(a_div_col10_time)



            }
            return li;
        }
    }
})()
